package com.huawei.appgallery.forum.section.card;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.forum.base.card.ForumCard;
import com.huawei.appgallery.forum.posts.api.IPostDetailProtocol;
import com.huawei.appgallery.forum.section.bean.ForumNoticeCardBean;
import com.huawei.appgallery.forum.section.bean.Notice;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import java.util.List;
import o.azb;
import o.cab.e;
import o.cab.i;
import o.cab.j;
import o.cgz;
import o.chy;
import o.cii;
import o.cil;
import o.cim.a;
import o.dof;
import o.evk;
import o.fho;
import o.fiu;
import o.fjb;

public class ForumNoticeCard extends ForumCard {
    private LinearLayout ˋ;
    private View ˎ;
    private ForumNoticeCardBean ˏ;

    public ForumNoticeCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ʽ(view);
        this.ˋ = (LinearLayout) view.findViewById(e.ˊॱ);
        this.ˎ = view.findViewById(e.ॱʼ);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        if (cardBean instanceof ForumNoticeCardBean) {
            this.ˏ = (ForumNoticeCardBean) cardBean;
            List ˊ = ((ForumNoticeCardBean) cardBean).ˊ();
            if (ˊ == null || ˊ.size() <= 0) {
                this.ˎ.setVisibility(8);
                return;
            }
            LayoutInflater from = LayoutInflater.from(this.ʼॱ);
            OnClickListener ˋ = ˋ();
            for (int i = 0; i < ˊ.size(); i++) {
                Notice notice = (Notice) ˊ.get(i);
                View inflate = from.inflate(ˎ(), null);
                if (!(this instanceof BuoyForumNoticeCard)) {
                    azb.ˏ(inflate);
                }
                ((TextView) inflate.findViewById(e.ॱˎ)).setText(notice.ˊ());
                if (i == ˊ.size() - 1) {
                    inflate.findViewById(e.ʻॱ).setVisibility(8);
                }
                this.ˋ.addView(inflate, new LayoutParams(-1, -2));
                inflate.setTag(notice);
                inflate.findViewById(e.ॱˋ).setOnClickListener(ˋ);
            }
            this.ˎ.setVisibility(0);
        }
    }

    public void ॱ(chy o_chy) {
    }

    public OnClickListener ˋ() {
        return new OnClickListener(this) {
            final /* synthetic */ ForumNoticeCard ˋ;

            {
                this.ˋ = r1;
            }

            public void onClick(View view) {
                Object tag = view.getTag();
                if (tag instanceof Notice) {
                    Notice notice = (Notice) tag;
                    if (!dof.ॱ(notice.ॱॱ())) {
                        if (notice.ॱॱ().startsWith("forum|topic_detail|")) {
                            cil.ˋ(this.ˋ.ʼॱ, new a(notice).ˋ());
                            this.ˋ.ॱ((Notice) tag);
                            return;
                        }
                        Context context = this.ˋ.ˊˋ.getContext();
                        if (context != null && !cii.ˊ().ˊ(context, notice)) {
                            evk.ˏ(context, j.ॱ, 0).ˋ();
                        }
                    }
                }
            }
        };
    }

    private void ॱ(Notice notice) {
        fjb ˎ = fho.ˏ().ˋ("Posts").ˎ("post.detail.activity");
        IPostDetailProtocol iPostDetailProtocol = (IPostDetailProtocol) ˎ.ˊ();
        if (this.ˏ != null) {
            iPostDetailProtocol.setDomainId(this.ˏ.ॱ());
            if (this.ˏ.ᐝ()) {
                iPostDetailProtocol.setSourceType(1);
            }
        }
        iPostDetailProtocol.setUri(notice.ॱॱ());
        iPostDetailProtocol.setDomainId(notice.ॱ());
        fiu.ˊ().ˏ(this.ʼॱ, ˎ);
    }

    protected int ˎ() {
        return i.ˋ;
    }
}
